package other

import (
	"fmt"
	"os"
	"runtime"
)

func RunTest() {
	fmt.Println("cpus:", runtime.NumCPU())
	fmt.Println("gorooot:", runtime.GOROOT())
	fmt.Println("archive:", runtime.GOOS)
}

// Gosched： 让出当前goroutine的cpu， 当一个goroutine发生阻塞，Go 会自动地把与该goroutine处于同一系统线程的其他gorouutine转移
// 到另一个系统线程上去，达到这些goroutine不阻塞的目的。
func RunTest2() {
	exit := make(chan int)
	go func() {
		defer close(exit)
		go func() {
			fmt.Println("b")
		}()
	}()

	for i := 0; i < 4; i++ {
		fmt.Println("a:", i)

		if i == 1 {
			runtime.Gosched()
		}
	}
	<-exit

	info, _ := os.Stat("base1.go")
	fmt.Println(info)
}
